/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * laser_entradas_catalogo_patrones_detalle.java
 *
 * Created on 19/01/2012, 09:05:39 AM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;


/**
 *
 * @author Michelle
 */
public class laser_entradas_catalogo_patrones_detalle extends javax.swing.JFrame {

        private javax.swing.table.DefaultTableModel jtable_modelo_maquilla;
        private javax.swing.table.DefaultTableModel jtable_modelo_inspat_historial;

        private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
        private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");

        DecimalFormat miformat = new DecimalFormat("############.####");

        private bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
        private ResultSet rs = null;
        int controlcombo=0,opcionform=0;

    /** Creates new form laser_entradas_catalogo_patrones_detalle */
    public laser_entradas_catalogo_patrones_detalle() {
        initComponents();
    }
 
    public laser_entradas_catalogo_patrones_detalle(int opcion,String idinsumo,String descripcion) {
        this.iniciar_modelo_patroneshistorial();
        initComponents();
        if(opcion==1)
            {
                opcionform=1;
                this.carga_datos_catinsumospatrones(1, 0, idinsumo);
                this.setTitle("S.I. Patrones Corte y Grabad Detalle:"+idinsumo+" "+descripcion);
                this.jtf_descripcion.requestFocus();
                this.carga_datos_catinsumospatroneshis(2, idinsumo);
                this.load_insumosfoto(1,idinsumo);
                controlcombo=1;
                //this.jcbx_fotosActionPerformed(evt);
                if (this.jcbx_fotos.getItemCount()>0)
                    {
                        this.jep_fotospatron.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://"+variables_global.getHost()+"/javaweb/laser/patrones/"+this.jcbx_fotos.getSelectedItem().toString()+"\" width=\"290\" height=\"290\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
                    }
                float piezasxfila=Float.parseFloat(this.jtf_anchomaterial.getText())/Float.parseFloat(this.jtf_anchopatron.getText());
                this.jtf_canpzaingresa.setText(String.valueOf(piezasxfila));
                this.calcularusumaterial();
            }
        if(opcion==2)
            {
                opcionform=2;
                this.jtf_idinsumo.setEditable(true);
                this.jtf_idinsumo.requestFocus();
                this.setTitle("S.I. :Alta de Patrones");
            }
        jt_catalogo_insumospathisto.getColumnModel().getColumn(0).setPreferredWidth(60);//status
        jt_catalogo_insumospathisto.getColumnModel().getColumn(1).setPreferredWidth(30);//tipo elemento
        jt_catalogo_insumospathisto.getColumnModel().getColumn(2).setPreferredWidth(60);//clave
        jt_catalogo_insumospathisto.getColumnModel().getColumn(3).setPreferredWidth(40);//descripcion
        jt_catalogo_insumospathisto.getColumnModel().getColumn(4).setPreferredWidth(40);//item
        jt_catalogo_insumospathisto.getColumnModel().getColumn(5).setPreferredWidth(60);//precio
        jt_catalogo_insumospathisto.getColumnModel().getColumn(6).setPreferredWidth(180);//precio
        
        
        
    }
private void iniciar_modelo_patroneshistorial()
    {
        jtable_modelo_inspat_historial=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_inspat_historial.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Folio</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Tipo</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Piezas</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Costo</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Imp.Costo</b></html>");
        jtable_modelo_inspat_historial.addColumn("<html><b>Observaciones</b></html>");
   }

private void load_insumosfoto(int opcion,String idinsumo){
            try
            {
             rs = x.sieuno_executediversosv2("select * from x1distribucion_laser_artic_insumos_fotos("+opcion+",'"+idinsumo+"','') as (id character varying(16),foto text);",variables_global.getconexiongral());
               while (rs.next())
                    {
                      this.jcbx_fotos.addItem(rs.getString("foto"));
                    }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }
private void insumosfoto_inserta(int opcion,String idinsumo,String foto){
            this.jcbx_fotos.removeAllItems();
            try
            {
             rs = x.sieuno_executediversosv2("select * from x1distribucion_laser_artic_insumos_fotos("+opcion+",'"+idinsumo+"','"+foto+"') as (id character varying(16),foto text);",variables_global.getconexiongral());
               while (rs.next())
                    {
                      this.jcbx_fotos.addItem(rs.getString("foto"));
                    }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }

    private void carga_datos_catinsumospatrones(int opcion, int opbuscamp,String busqueda)
 {
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");
        DecimalFormat miformatde = new DecimalFormat("###,###,###,###.###");
        DecimalFormat miformatpre = new DecimalFormat("############.####");
         DecimalFormat miformatseg = new DecimalFormat("############");
       float tiempoxpieza=0,tiempo=0;
       String texto="select * from x1distribucion_laser_artic_insumos_cat("+opcion+","+opbuscamp+",'"+busqueda.toUpperCase().trim()+"') as (idinsumo character varying(16),codigobarra character varying(16), idstatus smallint,describinsumo character varying(80),itemproveedor character varying(16),unidadsal character varying(3),unidadent character varying(3),factor numeric,unidadempake character varying(12),tipoelemento smallint,familiainsumo smallint,lineainsumo smallint,controlalmacen character varying(20),stockminimo numeric,stockmaximo numeric,precio numeric,precio2 numeric,ultimocosto numeric,costoprom numeric,fechaultcom date, fechaultventa date,idprovee character varying(16),impuesto numeric,impuesto2 numeric,usuario character varying(20),valorx character varying(20),obserinsumo text,describestatus text,describetipo text,describefamilia text,describelinea text)",textotiempo="";
       rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
       System.out.println(texto);
       try
        {
            while (rs.next())
                {
                    //fnewRow[0]=rs.getString ("describestatus");
                    //fnewRow[1]=rs.getString ("describetipo");
                    this.jtf_idinsumo.setText(rs.getString ("idinsumo"));
                    this.jtf_descripcion.setText(rs.getString ("describinsumo"));
                    //fnewRow[4]=rs.getString ("itemproveedor");
                    //fnewRow[5]=rs.getString ("unidadsal");
                     this.jtf_costopieza.setText(miformatpre.format(rs.getFloat("precio")));
                     this.jtf_tiemposegundo.setText(miformatseg.format(rs.getFloat("factor")*60));
                     this.jtf_factor.setText(miformatpre.format(rs.getFloat("factor")));
                     this.jtf_Preciominutos.setText(miformatseg.format(rs.getFloat("precio")/rs.getFloat("factor")));

                    this.jtf_anchopatron.setText(miformatde.format(rs.getFloat("stockminimo")));
                    this.jlbl_anchocm.setText(miformatde.format(rs.getFloat("stockminimo"))+"Cm");
                    this.jtf_alto.setText(miformatde.format(rs.getFloat("stockmaximo")));
                    this.jlbl_altocm.setText(miformatde.format(rs.getFloat("stockmaximo"))+"Cm");
                    
/*
                    tiempoxpieza=rs.getFloat("factor")*60;
                    if (tiempoxpieza>59)
                        {
                            tiempo=tiempoxpieza/60;
                            textotiempo=" MIN.";
                        }
                    else
                        {
                            tiempo=tiempoxpieza;
                            textotiempo=" SEG.";
                        }

                    fnewRow[9]=miformat.format(tiempo)+textotiempo;
                    fnewRow[10]="";
                    fnewRow[11]=rs.getString ("obserinsumo");
                    jtable_modelo_insumospatrones.addRow(fnewRow);
 */
                }

        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

 }


private void carga_datos_catinsumospatroneshis(int opcion, String busqueda)
 {
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");
        DecimalFormat miformatde = new DecimalFormat("###,###,###,###.##");
       while(jtable_modelo_inspat_historial.getRowCount()>0)jtable_modelo_inspat_historial.removeRow(0);
       Object[] fnewRow = new Object[7];
       float tiempoxpieza=0,tiempo=0;
       String texto="select * from x1distribucion_laser_artic_insumosentrada_doctos_detalle_import("+opcion+",'"+busqueda.toUpperCase().trim()+"') as (idreg integer,iddocto character varying(12),idarti character varying(16),cantidad numeric,factor numeric,cant_articulosal numeric,costo numeric,costoxpieza numeric,descuento1 numeric,descuento2 numeric,impuesto1 numeric,impuesto2 numeric,politicadesc smallint,tipocambio numeric,obserpartida character varying(60),piezasproduci numeric,importecosto numeric,describeinsumo character varying(80),unidadent character varying(3),stock_minimo numeric,stockmaximo numeric,idstatusdocume smallint,fechadocto date,idcliente character varying(12),idtipomaquila smallint,obserdocto character varying(80),describemaquila text)",textotiempo="";
       
       System.out.println(texto);
       try
        {
           rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
            while (rs.next())
                {
                    fnewRow[0]=this.fechaeuropea(rs.getString ("fechadocto"));
                    fnewRow[1]=rs.getString ("iddocto");
                    fnewRow[2]=rs.getString ("describemaquila");
                    fnewRow[3]=rs.getString ("piezasproduci");

                    fnewRow[4]="<html><b>$"+miformatde.format(rs.getFloat("costoxpieza"))+"</b></html>";
                    fnewRow[5]=miformatde.format(rs.getFloat("costoxpieza")*rs.getFloat("piezasproduci"));
                    //fnewRow[3]=rs.getString ("describinsumo");
                    fnewRow[6]=rs.getString ("obserdocto");
                    //fnewRow[5]=rs.getString ("unidadsal");
                    //fnewRow[6]=miformatde.format((rs.getFloat("precio")/60)*(rs.getFloat("factor")*60));
                    //fnewRow[7]=rs.getString ("fechaultcom");
                    //fnewRow[8]=rs.getString ("idprovee");
                    //tiempoxpieza=rs.getFloat("factor")*60;
                    //if (tiempoxpieza>59)
                    //    {
                    //        tiempo=tiempoxpieza/60;
                    //        textotiempo=" MIN.";
                    //    }
                    //else
                    //    {
                    //        tiempo=tiempoxpieza;
                    //        textotiempo=" SEG.";
                    //    }
                    //fnewRow[7]=miformat.format(tiempo)+textotiempo;
                    //fnewRow[8]="";
                    //fnewRow[9]=rs.getString ("obserinsumo");
                    jtable_modelo_inspat_historial.addRow(fnewRow);
                }

        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

 }


private String  fechaeuropea(String fecha) {

         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;

    }
private String DiaSemana(String fe) {
         String dia = "";
       java.util.Date fecha=null;
         try
            {
             fecha = formateador.parse(fe);

           }
        catch (ParseException e)
            {
            //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }
private String mensajetiempo(int nd) {
     String mensaje="";
     if (nd==0)
				{
					mensaje="<html><b>Hoy</b></html>";
				}
		if (nd==1)
				{
					mensaje="<html><b>ayer</b></html>";
				}
		if (nd>1)
				{
					mensaje=" Hace " + nd + " Dias " ;
				}
 	return mensaje;
 }
private void calcularusumaterial()
        {
            float piezasxfila=0,totfilas=0,alturausada=0,filaajuste=0,filasneceenteras=0;
            String piezasxfilas[]=null,totfilass[]=null,alturausadas[]=null,puentedetexto="",puentefnece="";
            DecimalFormat miformat = new DecimalFormat("############.##");
            DecimalFormat miformatent = new DecimalFormat("############.##");
            DecimalFormat miformatuso = new DecimalFormat("############.####");

            piezasxfila=Float.parseFloat(this.jtf_anchomaterial.getText())/Float.parseFloat(this.jtf_anchopatron.getText());
            //this.jtf_piezasxfila.setText(miformat.format(piezasxfila).replace(".", ":"));
            puentedetexto=miformat.format(piezasxfila).replace(".", ":").replace(",", ":");
            piezasxfilas=puentedetexto.split(":");
            System.out.println(piezasxfilas[0]);
            this.jtf_piezasxfila.setText(miformatent.format(Float.parseFloat(piezasxfilas[0])));

            totfilas=Float.parseFloat(this.jtf_canpzaingresa.getText())/Float.parseFloat(piezasxfilas[0]);
            //this.jtf_filasnecesarias.setText(miformat.format(totfilas).replace(".", ":"));
            puentefnece=miformat.format(totfilas).replace(".", ":").replace(",", ":");
            totfilass=puentefnece.split(":");
            filasneceenteras=Float.parseFloat(totfilass[0]);
            if (totfilas>filasneceenteras)
                    {
                        filaajuste=1;
                    }
            puentefnece=miformat.format(Float.parseFloat(totfilass[0])+filaajuste);
            this.jtf_filasnecesarias.setText(miformat.format(Float.parseFloat(totfilass[0])+filaajuste));
            alturausada=Float.parseFloat(puentefnece)*Float.parseFloat(this.jtf_alto.getText());
            //alturausadas=miformat.format(alturausada).split(".");
            this.jtf_alturamaterial.setText(miformat.format(alturausada));
            this.jtf_alturamt.setText(miformat.format(alturausada/100));
            this.jtf_usomatcms.setText(miformatuso.format(Float.parseFloat(this.jtf_alto.getText().toString())/(Float.parseFloat(this.jtf_piezasxfila.getText().toString())/Float.parseFloat(this.jtf_piezasterminadas.getText().toString()))));
            this.jtf_usomatmetros.setText(miformatuso.format(Float.parseFloat(this.jtf_usomatcms.getText().toString())/100));
        }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jtf_idinsumo = new javax.swing.JTextField();
        jbtn_guardarcambios = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtf_descripcion = new javax.swing.JTextField();
        jtf_anchopatron = new javax.swing.JTextField();
        jlbl_ancho = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtf_alto = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jep_fotospatron = new javax.swing.JEditorPane();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jcbx_fotos = new javax.swing.JComboBox();
        jtf_foto = new javax.swing.JTextField();
        jbtn_buscar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jt_catalogo_insumospathisto = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        };
        ;
        jScrollPane2 = new javax.swing.JScrollPane();
        jep_obserpartida = new javax.swing.JEditorPane();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jlbl_anchocm = new javax.swing.JLabel();
        jlbl_altocm = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel23 = new javax.swing.JLabel();
        jtf_anchomaterial = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtf_piezasxfila = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jtf_piezasterminadas = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jtf_usomatcms = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtf_canpzaingresa = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtf_filasnecesarias = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtf_alturamaterial = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtf_alturamt = new javax.swing.JTextField();
        jbtn_calcular = new javax.swing.JButton();
        jtf_usomatmetros = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jtf_costopieza = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jtf_tiemposegundo = new javax.swing.JTextField();
        jtf_factor = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jtf_Preciominutos = new javax.swing.JTextField();
        jbtn_guardarcambios1 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jta_archivo = new javax.swing.JTextArea();
        jLabel20 = new javax.swing.JLabel();
        jbtn_importar = new javax.swing.JButton();
        jbtn_importar1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmni_guardar = new javax.swing.JMenuItem();
        jmni_salir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jmn_escape = new javax.swing.JMenuItem();
        jmni_buscar = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jtf_idinsumo.setEditable(false);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(laser_entradas_catalogo_patrones_detalle.class);
        jtf_idinsumo.setText(resourceMap.getString("jtf_idinsumo.text")); // NOI18N
        jtf_idinsumo.setName("jtf_idinsumo"); // NOI18N
        jtf_idinsumo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_idinsumoActionPerformed(evt);
            }
        });

        jbtn_guardarcambios.setIcon(resourceMap.getIcon("jbtn_guardarcambios.icon")); // NOI18N
        jbtn_guardarcambios.setText(resourceMap.getString("jbtn_guardarcambios.text")); // NOI18N
        jbtn_guardarcambios.setName("jbtn_guardarcambios"); // NOI18N
        jbtn_guardarcambios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_guardarcambiosActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jtf_descripcion.setText(resourceMap.getString("jtf_descripcion.text")); // NOI18N
        jtf_descripcion.setName("jtf_descripcion"); // NOI18N
        jtf_descripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_descripcionActionPerformed(evt);
            }
        });

        jtf_anchopatron.setText(resourceMap.getString("jtf_anchopatron.text")); // NOI18N
        jtf_anchopatron.setName("jtf_anchopatron"); // NOI18N
        jtf_anchopatron.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_anchopatronActionPerformed(evt);
            }
        });

        jlbl_ancho.setText(resourceMap.getString("jlbl_ancho.text")); // NOI18N
        jlbl_ancho.setName("jlbl_ancho"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jtf_alto.setText(resourceMap.getString("jtf_alto.text")); // NOI18N
        jtf_alto.setName("jtf_alto"); // NOI18N
        jtf_alto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_altoActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jep_fotospatron.setContentType(resourceMap.getString("jep_fotospatron.contentType")); // NOI18N
        jep_fotospatron.setName("jep_fotospatron"); // NOI18N
        jScrollPane1.setViewportView(jep_fotospatron);

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jLabel5.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        jcbx_fotos.setName("jcbx_fotos"); // NOI18N
        jcbx_fotos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbx_fotosActionPerformed(evt);
            }
        });

        jtf_foto.setText(resourceMap.getString("jtf_foto.text")); // NOI18N
        jtf_foto.setToolTipText(resourceMap.getString("jtf_foto.toolTipText")); // NOI18N
        jtf_foto.setName("jtf_foto"); // NOI18N
        jtf_foto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_fotoActionPerformed(evt);
            }
        });

        jbtn_buscar.setIcon(resourceMap.getIcon("jbtn_buscar.icon")); // NOI18N
        jbtn_buscar.setText(resourceMap.getString("jbtn_buscar.text")); // NOI18N
        jbtn_buscar.setName("jbtn_buscar"); // NOI18N
        jbtn_buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_buscarActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jt_catalogo_insumospathisto.setModel(this.jtable_modelo_inspat_historial);
        jt_catalogo_insumospathisto.setName("jt_catalogo_insumospathisto"); // NOI18N
        jt_catalogo_insumospathisto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_catalogo_insumospathistoMouseClicked(evt);
                if(evt.getClickCount() >= 1)
                {
                    dioclick(evt);
                }
            }
        });
        jScrollPane4.setViewportView(jt_catalogo_insumospathisto);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jep_obserpartida.setName("jep_obserpartida"); // NOI18N
        jScrollPane2.setViewportView(jep_obserpartida);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 491, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel6))))
        );

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jlbl_anchocm.setFont(resourceMap.getFont("jlbl_anchocm.font")); // NOI18N
        jlbl_anchocm.setText(resourceMap.getString("jlbl_anchocm.text")); // NOI18N
        jlbl_anchocm.setName("jlbl_anchocm"); // NOI18N

        jlbl_altocm.setFont(resourceMap.getFont("jlbl_altocm.font")); // NOI18N
        jlbl_altocm.setText(resourceMap.getString("jlbl_altocm.text")); // NOI18N
        jlbl_altocm.setName("jlbl_altocm"); // NOI18N

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        jtf_anchomaterial.setText(resourceMap.getString("jtf_anchomaterial.text")); // NOI18N
        jtf_anchomaterial.setToolTipText(resourceMap.getString("jtf_anchomaterial.toolTipText")); // NOI18N
        jtf_anchomaterial.setName("jtf_anchomaterial"); // NOI18N
        jtf_anchomaterial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_anchomaterialActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jtf_piezasxfila.setEditable(false);
        jtf_piezasxfila.setFont(resourceMap.getFont("jtf_piezasxfila.font")); // NOI18N
        jtf_piezasxfila.setText(resourceMap.getString("jtf_piezasxfila.text")); // NOI18N
        jtf_piezasxfila.setName("jtf_piezasxfila"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jtf_piezasterminadas.setText(resourceMap.getString("jtf_piezasterminadas.text")); // NOI18N
        jtf_piezasterminadas.setToolTipText(resourceMap.getString("jtf_piezasterminadas.toolTipText")); // NOI18N
        jtf_piezasterminadas.setName("jtf_piezasterminadas"); // NOI18N
        jtf_piezasterminadas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_piezasterminadasActionPerformed(evt);
            }
        });

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jtf_usomatcms.setEditable(false);
        jtf_usomatcms.setFont(resourceMap.getFont("jtf_usomatcms.font")); // NOI18N
        jtf_usomatcms.setText(resourceMap.getString("jtf_usomatcms.text")); // NOI18N
        jtf_usomatcms.setToolTipText(resourceMap.getString("jtf_usomatcms.toolTipText")); // NOI18N
        jtf_usomatcms.setName("jtf_usomatcms"); // NOI18N
        jtf_usomatcms.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_usomatcmsActionPerformed(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jtf_canpzaingresa.setText(resourceMap.getString("jtf_canpzaingresa.text")); // NOI18N
        jtf_canpzaingresa.setToolTipText(resourceMap.getString("jtf_canpzaingresa.toolTipText")); // NOI18N
        jtf_canpzaingresa.setName("jtf_canpzaingresa"); // NOI18N
        jtf_canpzaingresa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_canpzaingresaActionPerformed(evt);
            }
        });

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jtf_filasnecesarias.setEditable(false);
        jtf_filasnecesarias.setFont(resourceMap.getFont("jtf_filasnecesarias.font")); // NOI18N
        jtf_filasnecesarias.setText(resourceMap.getString("jtf_filasnecesarias.text")); // NOI18N
        jtf_filasnecesarias.setName("jtf_filasnecesarias"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jtf_alturamaterial.setEditable(false);
        jtf_alturamaterial.setFont(resourceMap.getFont("jtf_alturamaterial.font")); // NOI18N
        jtf_alturamaterial.setText(resourceMap.getString("jtf_alturamaterial.text")); // NOI18N
        jtf_alturamaterial.setName("jtf_alturamaterial"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jtf_alturamt.setEditable(false);
        jtf_alturamt.setFont(resourceMap.getFont("jtf_alturamt.font")); // NOI18N
        jtf_alturamt.setText(resourceMap.getString("jtf_alturamt.text")); // NOI18N
        jtf_alturamt.setName("jtf_alturamt"); // NOI18N

        jbtn_calcular.setIcon(resourceMap.getIcon("jbtn_calcular.icon")); // NOI18N
        jbtn_calcular.setText(resourceMap.getString("jbtn_calcular.text")); // NOI18N
        jbtn_calcular.setName("jbtn_calcular"); // NOI18N
        jbtn_calcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_calcularActionPerformed(evt);
            }
        });

        jtf_usomatmetros.setEditable(false);
        jtf_usomatmetros.setFont(resourceMap.getFont("jtf_usomatmetros.font")); // NOI18N
        jtf_usomatmetros.setText(resourceMap.getString("jtf_usomatmetros.text")); // NOI18N
        jtf_usomatmetros.setToolTipText(resourceMap.getString("jtf_usomatmetros.toolTipText")); // NOI18N
        jtf_usomatmetros.setName("jtf_usomatmetros"); // NOI18N
        jtf_usomatmetros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_usomatmetrosActionPerformed(evt);
            }
        });

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_alturamaterial, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtf_canpzaingresa, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(181, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtf_anchomaterial)
                            .addComponent(jtf_usomatcms, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jbtn_calcular)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jLabel8))
                            .addComponent(jLabel15)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jtf_usomatmetros, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtf_alturamt, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(15, 15, 15)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtf_filasnecesarias, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                                    .addComponent(jtf_piezasxfila, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_piezasterminadas, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel11)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jtf_anchomaterial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jtf_piezasterminadas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtf_usomatcms, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(jtf_usomatmetros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(25, 25, 25)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jtf_filasnecesarias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_canpzaingresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtf_piezasxfila, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jbtn_calcular))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jtf_alturamaterial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jtf_alturamt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jtf_costopieza.setEditable(false);
        jtf_costopieza.setText(resourceMap.getString("jtf_costopieza.text")); // NOI18N
        jtf_costopieza.setToolTipText(resourceMap.getString("jtf_costopieza.toolTipText")); // NOI18N
        jtf_costopieza.setName("jtf_costopieza"); // NOI18N
        jtf_costopieza.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_costopiezaActionPerformed(evt);
            }
        });

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        jtf_tiemposegundo.setText(resourceMap.getString("jtf_tiemposegundo.text")); // NOI18N
        jtf_tiemposegundo.setToolTipText(resourceMap.getString("jtf_tiemposegundo.toolTipText")); // NOI18N
        jtf_tiemposegundo.setName("jtf_tiemposegundo"); // NOI18N
        jtf_tiemposegundo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_tiemposegundoActionPerformed(evt);
            }
        });

        jtf_factor.setEditable(false);
        jtf_factor.setText(resourceMap.getString("jtf_factor.text")); // NOI18N
        jtf_factor.setToolTipText(resourceMap.getString("jtf_factor.toolTipText")); // NOI18N
        jtf_factor.setName("jtf_factor"); // NOI18N
        jtf_factor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_factorActionPerformed(evt);
            }
        });

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jtf_Preciominutos.setText(resourceMap.getString("jtf_Preciominutos.text")); // NOI18N
        jtf_Preciominutos.setToolTipText(resourceMap.getString("jtf_Preciominutos.toolTipText")); // NOI18N
        jtf_Preciominutos.setName("jtf_Preciominutos"); // NOI18N
        jtf_Preciominutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_PreciominutosActionPerformed(evt);
            }
        });

        jbtn_guardarcambios1.setIcon(resourceMap.getIcon("jbtn_guardarcambios1.icon")); // NOI18N
        jbtn_guardarcambios1.setText(resourceMap.getString("jbtn_guardarcambios1.text")); // NOI18N
        jbtn_guardarcambios1.setToolTipText(resourceMap.getString("jbtn_guardarcambios1.toolTipText")); // NOI18N
        jbtn_guardarcambios1.setName("jbtn_guardarcambios1"); // NOI18N
        jbtn_guardarcambios1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_guardarcambios1ActionPerformed(evt);
            }
        });

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jta_archivo.setColumns(20);
        jta_archivo.setRows(5);
        jta_archivo.setName("jta_archivo"); // NOI18N
        jScrollPane3.setViewportView(jta_archivo);

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        jbtn_importar.setIcon(resourceMap.getIcon("jbtn_importar.icon")); // NOI18N
        jbtn_importar.setText(resourceMap.getString("jbtn_importar.text")); // NOI18N
        jbtn_importar.setName("jbtn_importar"); // NOI18N
        jbtn_importar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_importarActionPerformed(evt);
            }
        });

        jbtn_importar1.setIcon(null);
        jbtn_importar1.setText(resourceMap.getString("jbtn_importar1.text")); // NOI18N
        jbtn_importar1.setName("jbtn_importar1"); // NOI18N
        jbtn_importar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_importar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 258, Short.MAX_VALUE)
                        .addComponent(jlbl_altocm, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel17)
                                    .addComponent(jlbl_ancho))))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jtf_idinsumo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jbtn_buscar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtf_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel5)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jtf_anchopatron, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jtf_factor, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel16)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtf_costopieza, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(21, 21, 21)
                                        .addComponent(jtf_alto, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(23, 23, 23)
                                        .addComponent(jLabel18)
                                        .addGap(18, 18, 18)
                                        .addComponent(jtf_tiemposegundo, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel19)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jtf_Preciominutos, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(jbtn_guardarcambios1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(302, 302, 302))))))
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jbtn_importar, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addComponent(jbtn_importar1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlbl_anchocm, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7))
                    .addComponent(jScrollPane1)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jtf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jcbx_fotos, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(17, 17, 17))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jbtn_guardarcambios, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel1)
                    .addComponent(jtf_idinsumo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jbtn_buscar)
                    .addComponent(jLabel7)
                    .addComponent(jlbl_anchocm))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(156, 156, 156)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jlbl_altocm))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jtf_anchopatron, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jlbl_ancho))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jtf_alto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel3)
                                        .addComponent(jLabel18)
                                        .addComponent(jtf_tiemposegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel19)
                                        .addComponent(jtf_Preciominutos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(29, 29, 29)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel17)
                                    .addComponent(jtf_factor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel16)
                                    .addComponent(jtf_costopieza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(22, 22, 22)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel20)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtn_importar)
                            .addComponent(jbtn_importar1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtn_guardarcambios, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbtn_guardarcambios1))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcbx_fotos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtf_foto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jmni_guardar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0));
        jmni_guardar.setText(resourceMap.getString("jmni_guardar.text")); // NOI18N
        jmni_guardar.setName("jmni_guardar"); // NOI18N
        jmni_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_guardarActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_guardar);

        jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
        jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
        jmni_salir.setName("jmni_salir"); // NOI18N
        jmni_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_salirActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_salir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jmn_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jmn_escape.setText(resourceMap.getString("jmn_escape.text")); // NOI18N
        jmn_escape.setName("jmn_escape"); // NOI18N
        jmn_escape.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmn_escapeActionPerformed(evt);
            }
        });
        jMenu2.add(jmn_escape);

        jmni_buscar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK));
        jmni_buscar.setText(resourceMap.getString("jmni_buscar.text")); // NOI18N
        jmni_buscar.setName("jmni_buscar"); // NOI18N
        jmni_buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_buscarActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_buscar);

        jMenuBar1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1027, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 643, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
       if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0) {
             this.dispose();
        }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jmni_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_guardarActionPerformed
        // TODO add your handling code here:
        this.jbtn_guardarcambiosActionPerformed(evt);
    }//GEN-LAST:event_jmni_guardarActionPerformed

    private void jmn_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmn_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmn_escapeActionPerformed

    private void jbtn_guardarcambiosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarcambiosActionPerformed
        // TODO add your handling code here:
         if(JOptionPane.showConfirmDialog(null, "Desea Guardar Cambios Solo Sist. Laser?")==0) {
         if(opcionform==1)
            {
            int confirma=0;
            String texto="select * from x1distribucion_laser_artic_insumos_actualiza(1,'"+this.jtf_idinsumo.getText().trim().toUpperCase()+"','"+this.jtf_descripcion.getText().replace(",", " ").trim().toUpperCase()+"','"+this.jtf_anchopatron.getText().trim()+"','"+this.jtf_alto.getText().trim().toUpperCase()+"','','"+this.jtf_costopieza.getText().trim()+"','"+this.jtf_factor.getText().trim()+"')";
            System.out.println(texto);
            try
                {
                    rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                while (rs.next())
                        {
                             confirma=rs.getInt(1);
                        }
                }
                catch(Exception e)
                    {
                        System.out.println(e.getMessage());
                    }
            if (confirma==1)
                  {
                        JOptionPane.showMessageDialog(null,"Gracias datos Actualizados Correctamente", "Sistema Integral Insumos",1);
                  }
         else
                  {
                        JOptionPane.showMessageDialog(null,"Error Consulte con Su Administrador", "Sistema Integral Insumos",1);
                  }
         }//fin de la opcion para modificar
         if(opcionform==2)
            {
             this.jtf_factor.setText(miformat.format(Float.valueOf(this.jtf_tiemposegundo.getText())/60));
              String texto="select * from x1distribucion_laser_artic_insumos_insert('"+this.jtf_idinsumo.getText().toUpperCase().trim()+"','',1,'"+this.jtf_descripcion.getText().trim().toUpperCase().replace(",", "")+"','"+this.jtf_idinsumo.getText().trim().toUpperCase()+"','"+"PZ"+"','"+"PZ"+"',"+this.jtf_factor.getText()+",'','0','0','0','',"+this.jtf_anchopatron.getText().trim()+","+this.jtf_alto.getText().trim()+","+this.jtf_costopieza.getText().trim()+",0,0,0,0,'',0,0,'','','') as (idinsumo character varying(16),descripcion character varying(80),item character varying(16),unidad character varying(3),factor numeric,smin numeric,smax numeric,precio numeric);";

                    System.out.println(texto);
                    try {
                        rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                        while (rs.next())
                                 {

                                 }
                    } catch(Exception e)
                        {
                              System.out.println(e.getMessage());
                              JOptionPane.showMessageDialog(null,"Error conexion", "Sistema Integral(Integral) : Error",1);
                        }
            }
    }//fin del if ke pregunda si desea guardar los cambios
    }//GEN-LAST:event_jbtn_guardarcambiosActionPerformed

    private void jtf_descripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_descripcionActionPerformed
        // TODO add your handling code here:
        this.jtf_anchopatron.requestFocus();
    }//GEN-LAST:event_jtf_descripcionActionPerformed

    private void jtf_anchopatronActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_anchopatronActionPerformed
        // TODO add your handling code here:
        this.jlbl_anchocm.setText(this.jtf_anchopatron.getText());
        this.jtf_alto.requestFocus();
    }//GEN-LAST:event_jtf_anchopatronActionPerformed

    private void jtf_altoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_altoActionPerformed
        // TODO add your handling code here:
        this.jlbl_altocm.setText(this.jtf_alto.getText());
        this.jtf_tiemposegundo.requestFocus();
    }//GEN-LAST:event_jtf_altoActionPerformed

    private void jcbx_fotosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_fotosActionPerformed
        // TODO add your handling code here:
        if (controlcombo==1)
            {

                this.jep_fotospatron.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://"+variables_global.getHost()+"/javaweb/laser/patrones/"+this.jcbx_fotos.getSelectedItem().toString()+"\" width=\"290\" height=\"290\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
            }
                
    }//GEN-LAST:event_jcbx_fotosActionPerformed

    private void jtf_fotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_fotoActionPerformed
        // TODO add your handling code here:
       if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus datos?")==0)
          {
            this.insumosfoto_inserta(2, this.jtf_idinsumo.getText(), this.jtf_foto.getText().trim());
            if (this.jcbx_fotos.getItemCount()>0)
                {
                    this.jep_fotospatron.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://"+variables_global.getHost()+"/javaweb/laser/patrones/"+this.jcbx_fotos.getSelectedItem().toString()+"\" width=\"290\" height=\"290\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
                }
          }

    }//GEN-LAST:event_jtf_fotoActionPerformed

    private void jbtn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_buscarActionPerformed
        // TODO add your handling code here:
         String textbusca="";
         textbusca=JOptionPane.showInputDialog("Ingresa Clave:");
         if (textbusca.length() > 0)
            {
                this.jcbx_fotos.removeAllItems();
                this.carga_datos_catinsumospatrones(1, 0, textbusca.trim().toUpperCase());
                this.carga_datos_catinsumospatroneshis(2, textbusca.trim().toUpperCase());
                this.load_insumosfoto(1,textbusca.trim());
                this.setTitle("S.I. Patrones Corte y Grabad Detalle:"+this.jtf_idinsumo.getText()+" "+this.jtf_descripcion.getText());
                this.jtf_descripcion.requestFocus();
                controlcombo=1;
        //this.jcbx_fotosActionPerformed(evt);
                if (this.jcbx_fotos.getItemCount()>0)
                    {
                        this.jep_fotospatron.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://"+variables_global.getHost()+"/javaweb/laser/patrones/"+this.jcbx_fotos.getSelectedItem().toString()+"\" width=\"290\" height=\"290\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
                    }
            }
}//GEN-LAST:event_jbtn_buscarActionPerformed

    private void jmni_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_buscarActionPerformed
        // TODO add your handling code here:
        this.jbtn_buscarActionPerformed(evt);
    }//GEN-LAST:event_jmni_buscarActionPerformed

    private void jtf_anchomaterialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_anchomaterialActionPerformed
        // TODO add your handling code here:
        this.jtf_piezasterminadas.requestFocus();
    }//GEN-LAST:event_jtf_anchomaterialActionPerformed

    private void jtf_piezasterminadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_piezasterminadasActionPerformed
        // TODO add your handling code here:
        this.jtf_canpzaingresa.requestFocus();
        
}//GEN-LAST:event_jtf_piezasterminadasActionPerformed

    private void jtf_usomatcmsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_usomatcmsActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jtf_usomatcmsActionPerformed

    private void jtf_canpzaingresaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_canpzaingresaActionPerformed
        // TODO add your handling code here:
        this.jbtn_calcularActionPerformed(evt);
    }//GEN-LAST:event_jtf_canpzaingresaActionPerformed

    private void jbtn_calcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_calcularActionPerformed
        // TODO add your handling code here:
        this.calcularusumaterial();
}//GEN-LAST:event_jbtn_calcularActionPerformed

    private void jtf_usomatmetrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_usomatmetrosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtf_usomatmetrosActionPerformed

    private void jtf_costopiezaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_costopiezaActionPerformed
        // TODO add your handling code here:
        this.jbtn_guardarcambios.requestFocus();
}//GEN-LAST:event_jtf_costopiezaActionPerformed

    private void jtf_tiemposegundoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_tiemposegundoActionPerformed
        // TODO add your handling code here:
        this.jtf_factor.setText(miformat.format(Float.valueOf(this.jtf_tiemposegundo.getText())/60));
         float tiempominutos=0,costoproduccion=0;
         tiempominutos=(Float.valueOf(this.jtf_tiemposegundo.getText())/60);
         costoproduccion=tiempominutos*Float.valueOf(this.jtf_Preciominutos.getText());
         this.jtf_costopieza.setText(miformat.format(costoproduccion));
         this.jtf_Preciominutos.requestFocus();
}//GEN-LAST:event_jtf_tiemposegundoActionPerformed

    private void jtf_factorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_factorActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jtf_factorActionPerformed

    private void jtf_idinsumoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_idinsumoActionPerformed
        // TODO add your handling code here:
        this.jtf_descripcion.requestFocus();
    }//GEN-LAST:event_jtf_idinsumoActionPerformed

    private void jtf_PreciominutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_PreciominutosActionPerformed
        // TODO add your handling code here:
         float tiempominutos=0,costoproduccion=0;
         tiempominutos=(Float.valueOf(this.jtf_tiemposegundo.getText())/60);
         costoproduccion=tiempominutos*Float.valueOf(this.jtf_Preciominutos.getText());
         this.jtf_costopieza.setText(miformat.format(costoproduccion));
         this.jbtn_guardarcambios.requestFocus();
}//GEN-LAST:event_jtf_PreciominutosActionPerformed

    private void jbtn_guardarcambios1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarcambios1ActionPerformed
        // TODO add your handling code here:
         if(JOptionPane.showConfirmDialog(null, "<html><b><h2>Desea Guardar Cambios Laser y Creaciones?</h2></b></html>")==0) {
             String texto="";
             int confirma=0;
          if(opcionform==1)
            {
        
             texto="select * from x1distribucion_laser_artic_insumos_actualiza(1,'"+this.jtf_idinsumo.getText().trim().toUpperCase()+"','"+this.jtf_descripcion.getText().replace(",", " ").trim().toUpperCase()+"','"+this.jtf_anchopatron.getText().trim()+"','"+this.jtf_alto.getText().trim().toUpperCase()+"','','"+this.jtf_costopieza.getText().trim()+"','"+this.jtf_factor.getText().trim()+"')";
            System.out.println(texto);
            try
                {
                    rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                while (rs.next())
                        {
                             confirma=rs.getInt(1);
                        }
                }
                catch(Exception e)
                    {
                        System.out.println(e.getMessage());
                    }
            if (confirma==1)
                  {
                        JOptionPane.showMessageDialog(null,"Gracias datos Actualizados Correctamente", "Sistema Integral Insumos",1);
                  }
         else
                  {
                        JOptionPane.showMessageDialog(null,"Error Consulte con Su Administrador", "Sistema Integral Insumos",1);
                  }
         }//fin de la opcion para modificar
         if(opcionform==2)
            {
             this.jtf_factor.setText(miformat.format(Float.valueOf(this.jtf_tiemposegundo.getText())/60));
              texto="select * from x1distribucion_laser_artic_insumos_insert('"+this.jtf_idinsumo.getText().toUpperCase().trim()+"','',1,'"+this.jtf_descripcion.getText().trim().toUpperCase().replace(",", "")+"','"+this.jtf_idinsumo.getText().trim().toUpperCase()+"','"+"PZ"+"','"+"PZ"+"',"+this.jtf_factor.getText()+",'','0','0','0','',"+this.jtf_anchopatron.getText().trim()+","+this.jtf_alto.getText().trim()+","+this.jtf_costopieza.getText().trim()+",0,0,0,0,'',0,0,'','','') as (idinsumo character varying(16),descripcion character varying(80),item character varying(16),unidad character varying(3),factor numeric,smin numeric,smax numeric,precio numeric);";

                    System.out.println(texto);


                    try {
                        rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                        while (rs.next())
                                 {

                                 }
                    } catch(Exception e)
                        {
                              System.out.println(e.getMessage());
                              JOptionPane.showMessageDialog(null,"Error conexion", "Sistema Integral(Integral) : Error",1);
                        }
            }
 //---------------------------------------------------------------------------------------------------------------------------
        x.estableceConexioninvitada();
        int controlfolio=0;
        if(variables_global.getError_ingreso()==-1)
        {
            if(JOptionPane.showConfirmDialog(null, "Error! Servidor No responde,Intentolo mas Tarde?")==0)
                    {

                    }
        }
        else
        {

                        texto="select * from x1distribucion_insumos_articulos_insert_externo('"+this.jtf_idinsumo.getText().trim().toUpperCase()+"','"+this.jtf_descripcion.getText().replace(",", " ").trim().toUpperCase()+"',"+this.jtf_factor.getText()+",'',"+this.jtf_anchopatron.getText().trim()+","+this.jtf_alto.getText().trim().toUpperCase()+","+this.jtf_costopieza.getText()+",'"+variables_global.getLogin()+"','')";
                        System.out.println(texto);
                            try {
                                rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongralext());
                                while (rs.next())
                                        {
                                        controlfolio=rs.getInt(1);
                                        }
                                }
                                catch(Exception e)
                                    {
                                        System.out.println(e.getMessage());
                                        JOptionPane.showMessageDialog(null," Operacion Incorrecta ", "Sistema Integral(Corte Laser) : Error",1);
                                   }
                        if (controlfolio > 0)
                                {
                                    JOptionPane.showMessageDialog(null,"Operacion Correcta, Gracias", "Sistema Integral(Corte Laser) : Confirmacion",1);
                                }

            x.cierraConexionexterna(variables_global.getconexiongralext());
    }
         }

    }//GEN-LAST:event_jbtn_guardarcambios1ActionPerformed

    private void jbtn_importarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_importarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "<html><b><h2>Desea Importar Estos Articulos A Catalog Laser?</h2></b></html>")==0) {
            String arreglo_importa[]=this.jta_archivo.getText().split("\n");
            String arreglo_codigo[]=null;
            System.out.println("Estos tiene archivo:"+arreglo_importa.length);
            for (int i=0;i<arreglo_importa.length;i++) {
                arreglo_codigo=arreglo_importa[i].split("\t");
                this.jtf_idinsumo.setText(arreglo_codigo[0]);
                this.jtf_descripcion.setText(arreglo_codigo[1]);
                this.jtf_anchopatron.setText(arreglo_codigo[2]);
                this.jtf_alto.setText(arreglo_codigo[3]);
                this.jtf_tiemposegundo.setText(arreglo_codigo[4]);
                this.jtf_Preciominutos.setText(arreglo_codigo[5]);
                this.jbtn_guardarcambiosActionPerformed(evt);
            }
            this.jta_archivo.setText("");
        }
}//GEN-LAST:event_jbtn_importarActionPerformed

    private void jbtn_importar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_importar1ActionPerformed
        // TODO add your handling code here:
         if(JOptionPane.showConfirmDialog(null, "<html><b><h2>Desea Importar Estos Articulos A Catalog Laser?</h2></b></html>")==0) {
            String arreglo_importa[]=this.jta_archivo.getText().split("\n");
            String arreglo_codigo[]=null;
            System.out.println("Estos tiene archivo:"+arreglo_importa.length);
            for (int i=0;i<arreglo_importa.length;i++) {
                arreglo_codigo=arreglo_importa[i].split("\t");
                this.jtf_idinsumo.setText(arreglo_codigo[0]);
                this.jtf_descripcion.setText(arreglo_codigo[1]);
                this.jtf_anchopatron.setText(arreglo_codigo[2]);
                this.jtf_alto.setText(arreglo_codigo[3]);
                this.jtf_tiemposegundo.setText(arreglo_codigo[4]);
                this.jtf_Preciominutos.setText(arreglo_codigo[5]);
                this.jbtn_guardarcambios1ActionPerformed(evt);
            }
            this.jta_archivo.setText("");
        }
    }//GEN-LAST:event_jbtn_importar1ActionPerformed
private void jt_catalogo_insumospathistoMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
private void dioclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
            System.out.println("dio doble  click en subfamilia");
            int fila = jt_catalogo_insumospathisto.getSelectedRow();
            this.jep_obserpartida.setText(this.jtable_modelo_inspat_historial.getValueAt(fila, 6).toString());

    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new laser_entradas_catalogo_patrones_detalle().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtn_buscar;
    private javax.swing.JButton jbtn_calcular;
    private javax.swing.JButton jbtn_guardarcambios;
    private javax.swing.JButton jbtn_guardarcambios1;
    private javax.swing.JButton jbtn_importar;
    private javax.swing.JButton jbtn_importar1;
    private javax.swing.JComboBox jcbx_fotos;
    private javax.swing.JEditorPane jep_fotospatron;
    private javax.swing.JEditorPane jep_obserpartida;
    private javax.swing.JLabel jlbl_altocm;
    private javax.swing.JLabel jlbl_ancho;
    private javax.swing.JLabel jlbl_anchocm;
    private javax.swing.JMenuItem jmn_escape;
    private javax.swing.JMenuItem jmni_buscar;
    private javax.swing.JMenuItem jmni_guardar;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JTable jt_catalogo_insumospathisto;
    private javax.swing.JTextArea jta_archivo;
    private javax.swing.JTextField jtf_Preciominutos;
    private javax.swing.JTextField jtf_alto;
    private javax.swing.JTextField jtf_alturamaterial;
    private javax.swing.JTextField jtf_alturamt;
    private javax.swing.JTextField jtf_anchomaterial;
    private javax.swing.JTextField jtf_anchopatron;
    private javax.swing.JTextField jtf_canpzaingresa;
    private javax.swing.JTextField jtf_costopieza;
    private javax.swing.JTextField jtf_descripcion;
    private javax.swing.JTextField jtf_factor;
    private javax.swing.JTextField jtf_filasnecesarias;
    private javax.swing.JTextField jtf_foto;
    private javax.swing.JTextField jtf_idinsumo;
    private javax.swing.JTextField jtf_piezasterminadas;
    private javax.swing.JTextField jtf_piezasxfila;
    private javax.swing.JTextField jtf_tiemposegundo;
    private javax.swing.JTextField jtf_usomatcms;
    private javax.swing.JTextField jtf_usomatmetros;
    // End of variables declaration//GEN-END:variables

}
